<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>新增规则 - LRY 聚合系统</title>
  <link rel="icon" th:href="@{/static/favicon.ico}" type="image/ico">
  <meta name="keywords" content="LRY 聚合系统">
  <meta name="description" content="LRY 聚合系统">
  <meta name="author" content="pingc">
  <link th:href="@{/static/css/bootstrap.min.css}" rel="stylesheet">
  <link th:href="@{/static/css/materialdesignicons.min.css}" rel="stylesheet">
  <!--标签插件-->
  <link rel="stylesheet" th:href="@{/static/js/jquery-tags-input/jquery.tagsinput.min.css}">
  <link th:href="@{/static/css/animate.css}" rel="stylesheet">
  <link th:href="@{/static/css/style.min.css}" rel="stylesheet">
</head>

<body>
<div class="container-fluid p-t-15">

  <div class="row">
    <div class="col-lg-12">
      <div class="card">

        <div class="card-body">
          <form class="form-horizontal" id="form"  method="post"   action="#!" οnsubmit="return false">
            <input class="form-control" type="text" id="id" name="id" th:value="${fv.id}" style="display: none;">
            <div class="form-group">
              <label class="col-md-3 control-label" for="name">规则名称 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="name" name="name" th:value="${fv.name}" placeholder="请输入规则名.例如：王大锤小说网">
              </div>
              <h5>如需使用正则，用-!-来与xpath区分<br>注意：搜索页标题与标题规则除了自身页面，在其他页面必须均为空，否则会有异常</h5>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="url">源站网址 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="url" name="url" th:value="${fv.url}" placeholder="请输入源站网址，例如：www.baidu.com">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="protocol">源站协议 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="protocol" name="protocol" th:value="${fv.protocol}" placeholder="请输入源站协议，例如：https">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="search-url">搜索链接 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="search-url" name="searchUrl" th:value="${fv.searchUrl}" placeholder="请输入搜索链接，例如：https://www.baidu.com/s?wd=">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="fiction-url">搜索页：小说标题 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="fiction-title" name="fictionTitle" th:value="${fv.fictionTitle}" placeholder="请输入小说标题规则..">
              </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label" for="fiction-url">搜索页：小说链接 *</label>
                <div class="col-md-4">
                  <input class="form-control" type="text" id="fiction-url" name="fictionUrl" th:value="${fv.fictionUrl}" placeholder="请输入小说链接规则..">
                </div>
              </div>
              <div class="form-group">
              <label class="col-md-3 control-label" for="page">搜索页：下一页链接</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="page" name="page" th:value="${fv.page}" placeholder="请输入下一页链接规则..">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="title">小说标题 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="title" name="title" th:value="${fv.title}" placeholder="请输入小说标题规则..">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="descs">小说作者 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="author" name="author" th:value="${fv.author}" placeholder="请输入小说作者规则..">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="fiction-type">小说分类 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="fiction-type" name="fictionType" th:value="${fv.fictionType}" placeholder="请输入小说分类规则..">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="descs">小说简介 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="descs" name="descs" th:value="${fv.descs}" placeholder="请输入小说简介规则..">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="cover">小说封面 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="cover" name="cover" th:value="${fv.cover}" placeholder="请输入小说封面规则..">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="update-time">小说时间 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="update-Time" name="updateTime" th:value="${fv.updateTime}" placeholder="请输入小说时间规则..">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="chapter-title">章节标题 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="chapter-title" name="chapterTitle" th:value="${fv.chapterTitle}" placeholder="请输入章节标题规则..">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="chapter-url">章节链接 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="chapter-url" name="chapterUrl" th:value="${fv.chapterUrl}" placeholder="请输入章节链接规则..">
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-3 control-label" for="content">章节内容 *</label>
              <div class="col-md-4">
                <input class="form-control" type="text" id="content" name="content" th:value="${fv.content}" placeholder="请输入章节内容规则..">
              </div>
            </div>
            <div class="form-group">
              <div class="col-md-9 col-md-offset-3">
                <button class="btn btn-primary pst" type="button" >保存</button>
                <button class="btn btn-primary verify"  type="button" >验证是否可用</button>
                <a th:href="@{/admin/fiction_variable_list/{from}/{size} (from=1,size=10)}"><button class="btn btn-primary" type="button" th:if="${fv.id} ne null">返回</button></a>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" id="addcfmOverhaul">
  <div class="modal-dialog modal-sm" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="myLargeModalLabel">提示</h4>
      </div>
      <div class="modal-body">
        <input type="hidden" id="addHaulId" />
        <p>你确定提交数据吗？</p>
      </div>
      <div class="modal-footer">
        <button type="button" id="gb" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="addHaulBtn">确定</button>
      </div>
    </div>
  </div>
</div>

<!--验证-->
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" id="delcfmOverhaul">
  <div class="modal-dialog modal-sm" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title pst" >规则验证</h4>
      </div>
      <div class="modal-body">
        <input class="form-control" type="text" id="example-text-input" name="example-text-input" placeholder="搜索..">
      </div>
      <div class="modal-footer">
        <button type="button" id="gbb" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="haulBtn">确定</button>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript" th:src="@{/static/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/static/js/bootstrap.min.js}"></script>
<!--标签插件-->
<script th:src="@{/static/js/jquery-tags-input/jquery.tagsinput.min.js}"></script>
<!--消息提示-->
<script th:src="@{/static/js/bootstrap-notify.min.js}"></script>
<script type="text/javascript" th:src="@{/static/js/lightyear.js}"></script>
<script type="text/javascript" th:src="@{/static/js/main.min.js}"></script>
<script type="text/javascript">
  function showaddModal() {
    $("#addcfmOverhaul").modal({
      backdrop : "static",
      keyboard : false
    });
  }

  function addHaulinfo() {
    lightyear.loading('show');
    $('#gb').click();
    $.ajax({
      type:"post",    //请求类型，POST\GET，不写默认GET
      url:"/fictionVariable/insert",    //请求地址
      data:$("#form").serialize()
      ,
      dataType:"json",    //ajax接收响应的数据是什么格式。选填，不填时，根据服务端响应的类型 自动判断
      success:function(data){//请求成功回调函数，在服务端成功响应数据之后，调用这个函数，有一个参数，接收返回的数据
        lightyear.loading('hide');
        if(data.code==0){
          lightyear.notify('修改成功，页面即将自动跳转~', 'success', 3000);
          setTimeout(function () {  $(location).attr('href', "/admin/fiction_variable_list/1/10");}, 2000)
        }else{
          lightyear.notify('服务器错误，请稍后再试~', 'danger', 100);
        }


      },
      error:function(jqXHR,textStatus,errorThrown){    //请求失败调用的函数，共有三个参数。选填，可不填
        lightyear.loading('hide');
        lightyear.notify('服务器错误，请稍后再试~', 'danger', 100);
      }
    })
  }

  $(function() {
// 确定按钮的点击事件

    $("#addHaulBtn").click(function() {

      addHaulinfo();

    });

  });
  //使用下面的示例之前，应当先加载jquery.js插件
  $('.pst').on("click", function () {
    showaddModal()
  });



  //验证
  function showModal(fiction_id) {
    $("#haul").val(fiction_id);// 将模态框中需要删除的大修的ID设为需要删除的ID
    $("#delcfmOverhaul").modal({
      backdrop : "static",
      keyboard : false
    });
  }
  function fictionAdd() {
    lightyear.loading('show');
    $('#gbb').click();
  //验证操作
    $.ajax({
      type:"post",    //请求类型，POST\GET，不写默认GET
      url:"/fictionVariable/verifyFictionVariable/"+$("#example-text-input").val(),    //请求地址
      data:$("#form").serialize()
      ,
      dataType:"json",    //ajax接收响应的数据是什么格式。选填，不填时，根据服务端响应的类型 自动判断
      success:function(data){//请求成功回调函数，在服务端成功响应数据之后，调用这个函数，有一个参数，接收返回的数据
        lightyear.loading('hide');
        if(data.code==0){
          console.log(data);
          lightyear.notify('验证结果返回成功，F12打开控制台查看~', 'success', 3000);

        }else{
          lightyear.notify('验证失败，请查看规则是否有误~', 'danger', 100);
        }


      },
      error:function(jqXHR,textStatus,errorThrown){    //请求失败调用的函数，共有三个参数。选填，可不填
        lightyear.loading('hide');
        lightyear.notify('服务器错误，请稍后再试~', 'danger', 100);

      }
    })
  }
  $(function() {
// 确定按钮的点击事件
    $("#haulBtn").click(function() {
// ajax异步执行
      fictionAdd();
    });

  });

  //使用下面的示例之前，应当先加载jquery.js插件
  $('.verify').on("click", function () {
    showModal()
  });





</script>
</body>
</html>